package net.zoneland.zrdp.common.utils.sign;


import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.ArrayUtils;


/**
 * Md5加密方法
 *
 * @author zonevue
 */
public class Md5Utils {
    private Md5Utils() {
        throw new IllegalStateException("Utility class");
    }
    public static byte[] md5(final String s) {
        return DigestUtils.md5(s);
    }

    public static String toHex(final byte[] hash) {
        if (ArrayUtils.isEmpty(hash)) {
            return "";
        }
        return Hex.encodeHexString(hash);
    }

    public static String hash(final String s) {
        return DigestUtils.md5Hex(s);
    }
}
